package a02demo2;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test2 {
    public static void main(String[] args) {


        String s = "来黑马程序员学Java，" +
                "手机号：13888888888，15518721397" +
                "邮箱：123@qq.com" +
                "座机电话：01036517895,010-98951256" +
                "热线电话：400-618-9090,400-618-4000";

        String regex1 = "1[3-9]\\d{9}";
        Pattern p1 = Pattern.compile(regex1);
        Matcher m1 = p1.matcher(s);
        while (m1.find()) {
            String s1 = m1.group();
            System.out.println(s1);
        }

        System.out.println("-----------------");

        String regex2 = "\\w+@[\\w&&[^_]]{2,6}(\\.[a-zA-Z]{2,3}){1,2}";
        Pattern p2 = Pattern.compile(regex2);
        Matcher m2 = p2.matcher(s);
        while (m2.find()) {
            String s2 = m2.group();
            System.out.println(s2);
        }

        System.out.println("-----------------");

        String regex3 = "0\\d{2,3}-?[1-9]\\d{4,9}";
        Pattern p3 = Pattern.compile(regex3);
        Matcher m3 = p3.matcher(s);
        while (m3.find()) {
            String s3 = m3.group();
            System.out.println(s3);
        }

        System.out.println("-----------------");

        String regex4 = "400-?[1-9]\\d{2}-?[1-9]\\d{3}";
        Pattern p4 = Pattern.compile(regex4);
        Matcher m4 = p4.matcher(s);
        while (m4.find()) {
            String s4 = m4.group();
            System.out.println(s4);
        }
    }
}
